package core;

import com.google.gdata.data.docs.DocumentListEntry;

public class File {
	public static final String FILE_SEPERATOR = "/";

	private Directory _parentDirectory = null;
	private DocumentListEntry _documentListEntry = null;
	protected String _canonicalName = null;

	public File(Directory parentDirectory, DocumentListEntry documentListEntry) {
		this._parentDirectory = parentDirectory;
		this._documentListEntry = documentListEntry;

		if (parentDirectory == null) {
			this._canonicalName = File.FILE_SEPERATOR + this.getName();
			this._parentDirectory = (Directory) this;
		} else {
			this._canonicalName = parentDirectory.getCanonicalName() + File.FILE_SEPERATOR + this.getName();
		}
	}

	public DocumentListEntry getEntry() {
		return this._documentListEntry;
	}

	public Directory getParent() {
		return this._parentDirectory;
	}

	public String getName() {
		return this._documentListEntry.getTitle().getPlainText();
	}

	public boolean isFile() {
		return true;
	}

	public boolean isDirectory() {
		return false;
	}

	public String getCanonicalName() {
		return this._canonicalName;
	}
}
